<template>
	<yd-layout id='bdResult' class=''>
		<div class="header">
			<img v-if="dataObj.status==1" class="header_img" src="../../../assets/bd_img/success.png" alt="" />
			<img v-else class="header_img" src="../../../assets/bd_img/defeated.png" alt="" />
			<div class="header_content">
				<div class="num">
					<div class="num_c">{{dataObj.real_score}}</div>
					<span>分</span>
				</div>
				<div v-if="dataObj.status==1&&dataObj.last_level" class="label">亲爱的伙伴，恭喜你，毕业了</div>
				<div v-else-if="dataObj.status==1" class="label">恭喜你，成功通过本阶段学习测试~</div>
				<div v-else class="label">很遗憾，分数未达到80分，未通过本次测试</div>
				<div v-if="dataObj.status==1&&dataObj.last_level" @click="getDiploma" class="btn">领取毕业证</div>
				<div v-else-if="dataObj.status==1" @click="studyNext" class="btn">{{true?'学习下一阶段':'领取毕业证'}}</div>
				<div v-else class="btn" @click="anewStudy" style="color: #FE5742;">重新学习</div>
			</div>
			<!--<div v-if="dataObj.status===0" @click="once" class="once">再测一次</div>-->
		</div>
		<div class="title">错题解析</div>
		<div class="content">
			<div v-if="dataObj.real_score==dataObj.score" class="error">
				<div>太棒了，满分通过，没有错题哟～ </div>
				<div>知道是没有力量的，相信并做到才有力量</div>
			</div>
			<div class="lsit_topic" v-else>
				<div class="list" v-for="item in topicList">
					<div class="list_title">{{item.title}}</div>
					
					<div class="list_item" v-for="i,num in item.questionArr">
						<img v-if="i.a" src="../../../assets/bd_img/yes.png" alt="" />
						<span v-else></span>
						<div class="item_title c_size_30_42">{{num===0?'A、':num==1?'B、':num==2?'C、':'D、'}}{{i.q}}</div>
					</div>
					
					<div class="right_answer">正确答案：{{item.right_answer}}</div>
					<div class="answer_title">
						<i></i>
						<span>{{item.course_title}}</span>
					</div>
				</div>
			</div>
		</div>
	</yd-layout>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				dataObj:{},
				topicList:[],
			}
		},
		created() {},
		watch: {

		},
		computed: {

		},
		mounted() {
			this.getResult();
		},
		methods: {
			//重新学习
			anewStudy(){
				this.$router.push({
					name:'bd_studyStage',
					query:{
						id:this.dataObj.level_id
					}
				})
			},
			//学习下一阶段
			studyNext(){
				this.$router.push({
					name:'bd_studyStage',
					query:{
						id:this.dataObj.next_level
					}
				})
			},
			//在来一次
			once(){
				this.$router.push({
					name:'bd_stageTopic',
					query:{
						id:this.$route.query.id
					}
				})
			},
			//领取毕业证
			getDiploma() {
				this.$router.push({
					name: 'bd_diploma'
				})
			},
			getResult() {
				this.$root.ajax({
					name: 'bible/result',
					type:'get',
					params: {
						exam_id:this.$route.query.exam_id,
					}
				}).then((d) => {
					this.dataObj=Object.assign({},this.dataObj,d.data)
					for(let a =0;a<d.data.topics.length;a++){
						let arr = d.data.topics[a].answer.split(',');
						d.data.topics[a].questionArr=[]
						
						/******特别重要：下面的顺序不能改，只能A,B,C,D*******/
						d.data.topics[a].questionArr.push({q:d.data.topics[a].option_a,a:arr.includes('A'),str:'A'})
						d.data.topics[a].questionArr.push({q:d.data.topics[a].option_b,a:arr.includes('B'),str:'B'})
						d.data.topics[a].questionArr.push({q:d.data.topics[a].option_c,a:arr.includes('C'),str:'C'})
						d.data.topics[a].questionArr.push({q:d.data.topics[a].option_d,a:arr.includes('D'),str:'D'})
					}
					this.topicList=d.data.topics
				})
			}
		}
	}
</script>

<style lang="scss">
	@import './result.scss';
</style>